package upe.dsc.algorithms.util;

import java.util.Random;

/**
 * @author ajccl/danilo
 * 
 */
public class RandomDouble {
	private static Random random1 = new Random();
	private static Random random2 = new Random();
	
	public static double getRandomDouble(double n, int decimals) {
		double randDouble = random1.nextDouble();
		int randInt1 = Math.abs(random1.nextInt()) % (int)n;
		boolean isNegative = random1.nextBoolean();
		
		int randInt2 = Math.abs(random2.nextInt()) % decimals;
		double divisor = Math.pow(10, randInt2);
		
		double randNumber = (randInt1 + randDouble) / divisor;
		
		double value = 0.0;
		if (!isNegative) {
			value = randNumber;
		} else {
			value = randNumber * (-1);
		}
		
		return value;
	}
	
}
